package com.mercycrazy.recruit.exception;

import com.mercycrazy.recruit.enums.StatusCode;
import lombok.EqualsAndHashCode;
import lombok.Getter;

/**
 * 通用业务异常定义
 *
 * @author <a href="mailto:1443424326@qq.com">mercycrazy</a>
 * @since 2023-01-08
 */
@Getter
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {

    private final StatusCode statusCode;

    public BusinessException(StatusCode statusCode) {
        super(statusCode.getMessage());
        this.statusCode = statusCode;
    }

    /**
     * Grace Display Exception
     */
    public static void display(StatusCode statusCode) {
        throw new BusinessException(statusCode);
    }
}
